import pandas
from openpyxl.styles.builtins import total

if __name__ == '__main__':
  excel_file_path = '/Users/longhairen/Documents/pycharm/learn-python/data/students_scores.xlsx'
  score = pandas.read_excel(excel_file_path)
  print('\n原始数据\n', score)
  score = score.drop_duplicates()
  print('\n去重重复行\n', score)
  # score = score.fillna(0)
  # print('\n处理na为0\n', score)
  score = score.fillna(
    score.mean(numeric_only= True))  # 参考 https://zhuanlan.zhihu.com/p544195498
  print('\n处理na为该列均值\n', score)
  # 计算每行的总和（不包括姓名列）
  score['总分'] = score[['语文', '英语', '数学']].sum(axis=1)
  print('\n添加总和的列\n', score)